<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    const srcImg = 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1605722900651&di=9b53918af2fe5dec0e29cc50054a512d&imgtype=0&src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20181130%2F62e70b6fbc7c457db7ca392bd856fed1.jpeg';
    // const img = document.createElement('img');
    // img.src = './lalala.jpg'
    // document.body.appendChild(img)
    // const proxyImg = new Image;
    // proxyImg.onload = function () {
    //   img.src = srcImg;
    // }
    // proxyImg.src = srcImg;


    const imgNode = (function () {
      const img = document.createElement('img');
      document.body.appendChild(img)
      return {
        setSrc: function (src) {
          img.src = src
        }
      }
    })()

    const proxyImg = (function () {
      const img = new Image;
      img.onload = function () {
        imgNode.setSrc(this.src)
      }
      return {
        setSrc: function (src) {
          imgNode.setSrc('./lalala.jpg');
          img.src = src;
        }
      }
    })()
    proxyImg.setSrc(srcImg)
  </script>
</body>

</html>